From: kaf24@firebug.cl.cam.ac.uk Date: Wed, 5 Oct 2005 22:15:00 +0000 (+0100) Subject: Activate suspending/resuming of the TPM interface and add X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16763^2~25^2~3 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=c436ce043df0eec436d8019a404a2ef51ac1ec93;p=xen.git Activate suspending/resuming of the TPM interface and add some missing code to tpmif.py. Signed-off-by: Stefan Berger --- diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index 55c44f95aa..384f39ffcb 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -442,26 +442,32 @@ static int tpmfront_remove(struct xenbus_device *dev) return 0; } -static int tpmfront_suspend(struct xenbus_device *dev) +static int +tpmfront_suspend(struct xenbus_device *dev) { struct tpmfront_info *info = dev->data; struct tpm_private *tp = &my_private; + u32 ctr = 0; - /* lock so no app can send */ + /* lock, so no app can send */ down(&suspend_lock); - while (atomic_read(&tp->tx_busy)) { - printk("---- TPMIF: Outstanding request.\n"); -#if 0 + while (atomic_read(&tp->tx_busy) && ctr <= 25) { + if ((ctr % 10) == 0) + printk("INFO: Waiting for outstanding request.\n"); /* - * Would like to wait until the outstanding request - * has come back, but this does not work properly, yet. + * Wait for a request to be responded to. */ - interruptible_sleep_on_timeout(&tp->wait_q, - 100); -#else - break; -#endif + interruptible_sleep_on_timeout(&tp->wait_q, 100); + ctr++; + } + + if (atomic_read(&tp->tx_busy)) { + /* + * A temporary work-around. + */ + printk("WARNING: Resetting busy flag."); + atomic_set(&tp->tx_busy, 0); } unregister_xenbus_watch(&info->watch); @@ -469,44 +475,34 @@ static int tpmfront_suspend(struct xenbus_device *dev) kfree(info->backend); info->backend = NULL; - destroy_tpmring(info, tp); - - return 0; -} - -static int tpmif_recover(void) -{ return 0; } -static int tpmfront_resume(struct xenbus_device *dev) +static int +tpmfront_resume(struct xenbus_device *dev) { struct tpmfront_info *info = dev->data; - int err; + int err = talk_to_backend(dev, info); - err = talk_to_backend(dev, info); - if (!err) { - tpmif_recover(); - } - - /* unlock so apps can resume */ + /* unlock, so apps can resume sending */ up(&suspend_lock); return err; } -static void tpmif_connect(u16 evtchn, domid_t domid) +static void +tpmif_connect(u16 evtchn, domid_t domid) { int err = 0; struct tpm_private *tp = &my_private; tp->evtchn = evtchn; - tp->backend_id = domid; + tp->backend_id = domid; - err = bind_evtchn_to_irqhandler( - tp->evtchn, - tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp); - if ( err <= 0 ) { + err = bind_evtchn_to_irqhandler(tp->evtchn, + tpmif_int, SA_SAMPLE_RANDOM, "tpmif", + tp); + if (err <= 0) { WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err); return; } @@ -641,7 +637,7 @@ tpm_xmit(struct tpm_private *tp, if (NULL == txb) { DPRINTK("txb (i=%d) is NULL. buffers initilized?\n", i); - DPRINTK("Not transmittin anything!\n"); + DPRINTK("Not transmitting anything!\n"); spin_unlock_irq(&tp->tx_lock); return -EFAULT; } diff --git a/tools/python/xen/xend/server/tpmif.py b/tools/python/xen/xend/server/tpmif.py index 50e8f7f016..b5269a2cb0 100644 --- a/tools/python/xen/xend/server/tpmif.py +++ b/tools/python/xen/xend/server/tpmif.py @@ -39,9 +39,24 @@ class TPMifController(DevController): """@see DevController.getDeviceDetails""" devid = int(sxp.child_value(config, 'instance', '0')) - log.debug("The domain has a TPM with instance %d." % devid) + log.info("The domain has a TPM with instance %d." % devid) back = { 'instance' : "%i" % devid } front = { 'handle' : "%i" % devid } return (devid, back, front) + + def configuration(self, devid): + + log.info("The configuration method is called.") + + result = DevContoller.configuration(self, devid) + + (instance) = self.readBackend(devif, + 'instance') + + if instance: + result.append(['instance', instance]) + log.info("configuration: instance=%d." % instance) + + return result